MyObject = function() {
	var myFirstName='Jack';
	var myLastName='Slocum'; //sorry jack : )

    function getFirstName(){
		alert(myFirstName);
	}
	function getLastName(){
		alert(myLastName);
	}
    return {
		NickName1: 'Super Jack',
		NickName2: 'Good Futher Jack',
        init: function() {
            alert(this.NickName1); //在Public zone裡面的需要使用this.xxxx來存取變數
			alert(myFirstName);    //在Public zone裡面的直接使用 xxx來存取  private zone裡面的變數
        },
		other : function(){
			alert(this.NickName2); //在Public zone裡面的需要使用this.xxxx來存取變數
			alert(myLastName);    //在Public zone裡面的直接使用 xxx來存取  private zone裡面的變數
		}  //注意結尾的,需要去除不然龜毛的IE會拒絕執行
    };
}(); // 

MyObject.init();

var XmlGrid=function(){
		var sm;
		var ds;
		var cm;
		var grid;
		/**
		* 初始化 sm: RowSelectionModel
		*/
		function bulide_sm(){
			sm = new Ext.grid.RowSelectionModel({singleSelect:true});
		}
		/**
		* 初始化ds: Datasource
		*/
		function bulder_ds(){
			ds = new Ext.data.Store({
				// load using HTTP
				proxy: new Ext.data.HttpProxy({url: 'sheldon.xml'}),

				// the return will be XML, so lets set up a reader
				reader: new Ext.data.XmlReader({
					   // records will have an "Item" tag
					   record: 'Item',
					   id: 'ASIN',
					   totalRecords: '@total'
				   }, [
					   // set up the fields mapping into the xml doc
					   // The first needs mapping, the others are very basic
					   {name: 'Author', mapping: 'ItemAttributes > Author'},
					   'Title', 'Manufacturer', 'ProductGroup'
				   ])
			});
		}
		/**
		* 初始化cm: ColumnModel
		*/
		function bulder_cm(){
			cm = new Ext.grid.ColumnModel([
				{header: "Author", width: 120, dataIndex: 'Author'},
				{header: "Title", width: 180, dataIndex: 'Title'},
				{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
				{header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
			]);
			cm.defaultSortable = true;
		}
		return{
			init : function(){
				bulder_cm();
				bulide_sm();
				bulder_ds();
				this.init_grid(); //產生gird
				ds.load();
			},
			init_grid : function(){
			    // create the grid
				grid = new Ext.grid.Grid('test', {
					ds: ds,
					cm: cm,
			        selModel:sm,
			        enableColLock:false,
			        loadMask: true
				});
				grid.render();
			}
		}
	}();
Ext.onReady(XmlGrid.init,XmlGrid,true);
